﻿mainModule.factory("staticCacheSvc", ["dictionaryCacheSvc", "localizationCacheSvc", "cultureCacheSvc", "$http", "sessionStorageSvc", "settings", function (dictionaryCacheSvc, localizationCacheSvc, cultureCacheSvc, $http, sessionStorageSvc, settings) {
    "use strict";
    return {
        init: function () {
            return sessionStorageSvc.get("static-data", function () { return $http.get(settings.cmsBaseUrl + "api/static") }).then(function (data) {
                if (data) {
                    dictionaryCacheSvc.init(data.Dictionaries);
                    localizationCacheSvc.init(data.LocaleStrings);
                    cultureCacheSvc.init(data.Cultures);                    
                    settings.data = data.Settings;
                }
            });
        },
        reset: function () {
            sessionStorageSvc.remove("static-data");
            this.init();
        }
    }    
}]);